module ov5640 #(
    parameter
        OV5640_ADDR     = 8'h3c         ,
        SYS_FRQ         = 26'd50_000_000,
        I2C_FREQ        = 18'd250_000   ,
        FRAME_LINE      = 16'd640       ,
        FRAME_ROW       = 16'd480       ,
        FRAME_TOTLE_H   = 16'd1856      ,
        FRAME_TOTLE_V   = 16'd984       
)(
    input   clk             ,
    input   rst_n           ,
    inout   sccb_sda        ,
    output  sccb_scl        ,
    output  ov5640_init_done
);

wire            i2c_exec; 
wire            i2c_done;

wire            dri_clk;
wire            cam_clk;
wire            i2c_rh_wl;
wire [7:0]      i2c_data_r;
wire [23:0]     i2c_data;

// i2cÇý¶¯
i2c_dri #(
    .SLAVE_ADDR (OV5640_ADDR),
    .CLK_FREQ   (SYS_FRQ    ),
    .I2C_FREQ   (I2C_FREQ   )
) u_i2c_dri(
    .clk        (clk            ),
    .rst_n      (rst_n          ),
    .i2c_exec   (i2c_exec       ),
    .bit_ctrl   (1'd1           ),
    .i2c_rh_wl  (i2c_rh_wl      ),
    .i2c_addr   (i2c_data[23:8] ),
    .i2c_data_w (i2c_data[7:0]  ),
    .i2c_data_r (i2c_data_r     ),
    .i2c_done   (i2c_done       ),
    .scl        (sccb_scl       ),
    .sda        (sccb_sda       ),
    .dri_clk    (dri_clk        )
);    

// ov5640¼Ä´æÆ÷°ü
i2c_ov5640_rgb565_cfg u_cfg(
    .clk            (dri_clk            ),
    .rst_n          (rst_n              ),
    .i2c_data_r     (i2c_data_r         ),
    .i2c_done       (i2c_done           ),
    .cmos_h_pixel   (FRAME_LINE         ),
    .cmos_v_pixel   (FRAME_ROW          ),
    .total_h_pixel  (FRAME_TOTLE_H      ),
    .total_v_pixel  (FRAME_TOTLE_V      ),
    .i2c_exec       (i2c_exec           ),
    .i2c_data       (i2c_data           ),
    .i2c_rh_wl      (i2c_rh_wl          ),
    .init_done      (ov5640_init_done   )
);
endmodule